﻿using System;

namespace LayeredArchitectureSample.DomainModel
{
    [GenerateDataTransferObject(TemplateName = "DefaultDtoTemplate.tt")]
    public class Location : DomainObject
    {
        public Location(long id, string name) : base(id)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name");
            }

            Name = name;
        }

        public string Name { get; private set; }

        public bool Equals(Location other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;

            return base.Equals(other) && String.Equals(other.Name, Name, StringComparison.Ordinal);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            return Equals(obj as Location);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                return (base.GetHashCode()*397) ^ Name.GetHashCode();
            }
        }
    }
}